spitoi2c 2.2.0
Loading...
Searching...
No Matches
spitoi2c.h File Reference

This file contains API for SPI to I2C Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"

Go to the source code of this file.

Data Structures

struct  spitoi2c_t
 SPI to I2C Click context object. More...
struct  spitoi2c_cfg_t
 SPI to I2C Click configuration object. More...

Macros

#define SPITOI2C_CMD_WRITE   0x00
 SPI to I2C control commands.
#define SPITOI2C_CMD_READ   0x01
#define SPITOI2C_CMD_READ_AFTER_WRITE   0x02
#define SPITOI2C_CMD_WRITE_AFTER_WRITE   0x03
#define SPITOI2C_CMD_READ_BUFFER   0x06
#define SPITOI2C_CMD_SPI_CONFIG   0x18
#define SPITOI2C_CMD_WRITE_REG   0x20
#define SPITOI2C_CMD_READ_REG   0x21
#define SPITOI2C_CMD_DEEP_POWER_DOWN   0x30
#define SPITOI2C_CMD_READ_VERSION   0xFE
#define SPITOI2C_REG_IO_CONFIG   0x00
 SPI to I2C registers list.
#define SPITOI2C_REG_IO_STATE   0x01
#define SPITOI2C_REG_I2C_CLOCK   0x02
#define SPITOI2C_REG_I2C_TO   0x03
#define SPITOI2C_REG_I2C_STAT   0x04
#define SPITOI2C_REG_I2C_ADR   0x05
#define SPITOI2C_I2C_CLOCK_375_KHZ   5
 SPI to I2C I2C settings.
#define SPITOI2C_I2C_CLOCK_99_KHZ   19
#define SPITOI2C_I2C_CLOCK_7p4_KHZ   255
#define SPITOI2C_I2C_ADDR_127   0xFE
#define SPITOI2C_I2C_TO_DISABLE   0x00
#define SPITOI2C_I2C_STATUS_SUCCESS   0xF0
 SPI to I2C I2C status.
#define SPITOI2C_I2C_STATUS_TARGET_NACK   0xF1
#define SPITOI2C_I2C_STATUS_WRITE_NACK   0xF2
#define SPITOI2C_I2C_STATUS_BUSY   0xF3
#define SPITOI2C_I2C_STATUS_TIMEOUT   0xF8
#define SPITOI2C_I2C_STATUS_DATA_COUNT   0xF9
#define SPITOI2C_TIMEOUT_MS   3000
 SPI to I2C read timeout settings.
#define SPITOI2C_NO_PIN_MASK   0x00
 SPI to I2C pin mask values.
#define SPITOI2C_PIN_0_MASK   0x01
#define SPITOI2C_PIN_1_MASK   0x02
#define SPITOI2C_PIN_2_MASK   0x04
#define SPITOI2C_PIN_3_MASK   0x08
#define SPITOI2C_PIN_4_MASK   0x10
#define SPITOI2C_ALL_PINS_MASK   0x1F
#define SPITOI2C_ALL_OUT_PINS_MASK   0x0F
#define SPITOI2C_PIN_DIR_INPUT   0x00
 SPI to I2C pin direction settings.
#define SPITOI2C_PIN_DIR_OUTPUT_PP   0x02
#define SPITOI2C_PIN_DIR_OUTPUT_OD   0x03
#define SPITOI2C_PIN_DIR_MASK   0x03
#define SPITOI2C_I2C_READ_BIT   0x01
 SPI to I2C I2C read bit.
#define SPITOI2C_SPI_CONFIG_LSB_FIRST   0x81
 SPI to I2C SPI config bytes.
#define SPITOI2C_SPI_CONFIG_MSB_FIRST   0x42
#define SPITOI2C_DEEP_PDOWN_BYTE_0   0x5A
 SPI to I2C deep power down bytes.
#define SPITOI2C_DEEP_PDOWN_BYTE_1   0xA5
#define SPITOI2C_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.

Enumerations

enum  spitoi2c_return_value_t { SPITOI2C_OK = 0 , SPITOI2C_ERROR = -1 }
 SPI to I2C Click return value data. More...

Functions

void spitoi2c_cfg_setup (spitoi2c_cfg_t *cfg)
 SPI to I2C configuration object setup function.
err_t spitoi2c_init (spitoi2c_t *ctx, spitoi2c_cfg_t *cfg)
 SPI to I2C initialization function.
err_t spitoi2c_default_cfg (spitoi2c_t *ctx)
 SPI to I2C default configuration function.
err_t spitoi2c_gpio_write (spitoi2c_t *ctx, uint8_t gpio_data)
 SPI to I2C gpio write function.
err_t spitoi2c_gpio_read (spitoi2c_t *ctx, uint8_t *gpio_data)
 SPI to I2C gpio read function.
err_t spitoi2c_gpio_config (spitoi2c_t *ctx, uint8_t direction, uint8_t pin_mask)
 SPI to I2C gpio gpio config function.
err_t spitoi2c_read_i2c_status (spitoi2c_t *ctx, uint8_t *i2c_stat)
 SPI to I2C read i2c status function.
err_t spitoi2c_i2c_write (spitoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_in, uint8_t len)
 SPI to I2C i2c write function.
err_t spitoi2c_i2c_read (spitoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_out, uint8_t len)
 SPI to I2C i2c read function.
err_t spitoi2c_i2c_read_after_write (spitoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_in, uint8_t in_len, uint8_t *data_out, uint8_t out_len)
 SPI to I2C i2c read after write function.
err_t spitoi2c_i2c_write_after_write (spitoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_in1, uint8_t in1_len, uint8_t *data_in2, uint8_t in2_len)
 SPI to I2C i2c write after write function.
void spitoi2c_read_buffer (spitoi2c_t *ctx, uint8_t *data_out, uint8_t len)
 SPI to I2C read buffer function.
err_t spitoi2c_set_spi_config (spitoi2c_t *ctx, uint8_t spi_cfg)
 SPI to I2C set spi config function.
err_t spitoi2c_write_register (spitoi2c_t *ctx, uint8_t reg, uint8_t data_in)
 SPI to I2C write register function.
err_t spitoi2c_read_register (spitoi2c_t *ctx, uint8_t reg, uint8_t *data_out)
 SPI to I2C read register function.
void spitoi2c_deep_power_down (spitoi2c_t *ctx)
 SPI to I2C deep power down function.
void spitoi2c_wake_up (spitoi2c_t *ctx)
 SPI to I2C wake up function.
err_t spitoi2c_read_version (spitoi2c_t *ctx, uint8_t *version)
 SPI to I2C read version function.
void spitoi2c_enable_device (spitoi2c_t *ctx)
 SPI to I2C enable device function.
void spitoi2c_disable_device (spitoi2c_t *ctx)
 SPI to I2C disable device function.
uint8_t spitoi2c_get_int_pin (spitoi2c_t *ctx)
 SPI to I2C get int pin function.

Detailed Description

This file contains API for SPI to I2C Click Driver.

Enumeration Type Documentation

◆ spitoi2c_return_value_t

SPI to I2C Click return value data.

Predefined enum values for driver return values.

Enumerator
SPITOI2C_OK 
SPITOI2C_ERROR